package com.shangxia.monomer.business.xml;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

/**
 * @ProjectName: monomer
 * @ClassName: SendDataThread
 * @Time: 2021/10/2
 * @Author: zhouy
 * @Description:
 * @Experience:
 */
@Slf4j
@AllArgsConstructor
public class SendDataThread implements Runnable {

    private static Semaphore semaphore = new Semaphore(3);

    @Override
    public void run() {
        try {
            semaphore.acquire();
            System.out.println(Thread.currentThread().getName() + " start");
            log.info(Thread.currentThread().getName() + " start");
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            semaphore.release();
        }
        System.out.println(Thread.currentThread().getName() + " end");
        log.info(Thread.currentThread().getName() + " end");
    }
}
